package com.clps.cn.Activite03;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;

//全部流程的挂起
public class SuspendProcessDefinition {

    public static void main(String[] args) {

        //01得到ProcessEngine对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();

        //02得到RepositoryService
        RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();
        //差选流程的实例

        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey("holiday").singleResult();


        //得到流程定义是否为涨停状态
        boolean suspended = processDefinition.isSuspended();

        //05判断
        if(suspended){
            //说明是暂停，就可以激活
            repositoryService.activateProcessDefinitionById(processDefinition.getId(),true,null);
            System.out.println("实例:"+processDefinition.getId()+"激活");
        }else{
            repositoryService.suspendProcessDefinitionById(processDefinition.getId(),true,null);
            System.out.println("实例:"+processDefinition.getId()+"挂起");
        }
    }
}
